<?php
$debugOrder = FALSE;
require("../../class2.php");
require("library/api.php");
require(HEADERF);
// Check the order and payment status and gateway
// If gateway and all the rest are okay, display the payment info
$orderstatus = $tp->toDB($_GET['s']);
$paystatus = e107shop_get_order_field($tp->toDB($_GET['o']), '', "status");
$gwstatus = e107shop_get_order_field($tp->toDB($_GET['o']), '', "gateway");
if ($orderstatus == 1 && $paystatus == "pending" && $gwstatus == "offline") {
    e107shop_display_custom_page_info(e_PAGE, "top");
}
?>
<script language="Javascript">
function invoice() {
    window.open("invoice.php?o=<?=$_GET["o"]?>"), ("invoice");
}
</script>
<?php
switch($_GET["s"]){
    Case "1":
        if($shop_settings['customer_must_be_member'] == "yes" && !USER){
            include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_login.php");
            require('../../login.php');
        } else {
            if(ADMIN || e107shop_get_user_for_order($_GET["o"], USERNAME)==1) {
                $ns->tablerender($shop_settings["store_name"], e107shop_display_order($_GET["o"], $_GET["s"]));
                echo '<br /><center><input class="button350" type="button" OnClick="invoice();"  value="'
                .lan_printable_invoice.'"></center><br />';
            } elseif (e107shop_get_user_for_order($_GET["o"], "Guest")==1) {
                $ns->tablerender($shop_settings["store_name"], e107shop_display_order($_GET["o"], $_GET["s"]));
            } else {
                $ns->tablerender("", lan_no_perms_to_order);
            }
            e107shop_delete_cart($_GET["o"]);
            destroy_e107shop_cookie();
        }
        break;
    Case "2":
        $ns->tablerender("", lan_error_processing);
        destroy_e107shop_cookie();
        break;
    Case "3":
        $ns->tablerender("", lan_cart_not_found);
        break;
    Case "4":
        $ns->tablerender("", lan_payment_failed);
        break;
}
e107shop_display_custom_page_info(e_PAGE, "bottom");
require(FOOTERF);
